import React, { useState, useEffect } from 'react'
import { Table,Modal } from 'antd'
import { Link } from "react-router-dom"

export default function OperationlogList(props) {

  const [selectedRowKeys, setSelectedRowKeys] = useState([])
  const [resdata, setResData] = useState([])

  const [pageSize, setPageSize] = useState(10)
  const [pageSizeNow, setPageSizeNow] = useState(1)

  // 第几次


  const columns = [
    {
      title: '编号',
      dataIndex: 'CodeNumber',
    },
    {
      title: '操作时间',
      dataIndex: 'OperationTime',
    },
    {
      title: '操作人员',
      dataIndex: 'OperationPerson',
    },
    {
      title: 'IP',
      dataIndex: 'ip',
    },
    {
      title: '操作日志',
      dataIndex: 'OperationLog',
    },
  ];

  const data = [];

  for (let i = 0; i < 9; i++) {
    // console.log(2222);
    data.push({
      key: i,
      CodeNumber: '1000'+ i,
      OperationTime: '2022-01-0'+ (i + 1),
      OperationPerson: i % 2 == 0 ? '流氓丙':'土匪丁',
      ip: '183.'+ i + '4.135.1',
      OperationLog: i < 5? '编辑会员账号：炮灰乙':'',
    })
  }


  const getPage = (pageSizeNow, pageSize) => {
    console.log(typeof pageSizeNow);
    console.log(typeof pageSize);
    setPageSize(pageSize)
    setPageSizeNow(pageSizeNow)
  }



  const onSelectChange = selectedRowKeys => {
    console.log('selectedRowKeys changed: ', selectedRowKeys);
    setSelectedRowKeys(selectedRowKeys)
  };

  const rowSelection = {
    selectedRowKeys,
    onChange: onSelectChange,
    selections: [
      Table.SELECTION_ALL,
      Table.SELECTION_INVERT,
      Table.SELECTION_NONE,
      {
        key: 'odd',
        text: 'Select Odd Row',
        onSelect: changableRowKeys => {
          let newSelectedRowKeys = [];
          newSelectedRowKeys = changableRowKeys.filter((key, index) => {
            if (index % 2 !== 0) {
              return false;
            }
            return true;
          });
          setSelectedRowKeys(newSelectedRowKeys)
        },
      },
      {
        key: 'even',
        text: 'Select Even Row',
        onSelect: changableRowKeys => {
          let newSelectedRowKeys = [];
          newSelectedRowKeys = changableRowKeys.filter((key, index) => {
            if (index % 2 !== 0) {
              return true;
            }
            return false;
          });
          setSelectedRowKeys(newSelectedRowKeys)
        },
      },
    ],
  };


  return (
    <div>
      <Table columns={columns} dataSource={data}
        pagination={
          {
            total: data.length,
            showSizeChanger: true,
            showQuickJumper: true,
            showTotal: total => `共${Math.ceil(total / pageSize)}页/${total}条数据`,
            pageSizeOptions: ['10', '20', '30'],
            onChange: getPage,
          }
        }

      />
    </div>
  );
}
